namespace PHMEE.PHM.Algorithms.Basic;

/// <summary>
/// 功率谱算法
/// </summary>
public class PowerSpectrumAlg
{
    private readonly PowerSpectrumService.PowerSpectrumServiceClient _client;

    public PowerSpectrumAlg(PowerSpectrumService.PowerSpectrumServiceClient client)
    {
        _client = client;
    }
    
    /// <summary>
    /// 功率谱算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public PowerSpectrumResponse PowerSpectrum(float[] accData, float sampleRate)
    {
        var request = new PowerSpectrumRequest
        {
            AccData = {accData},
            SampleRate = sampleRate
        };
        
        return _client.PowerSpectrumAlg(request);
    }
    
    /// <summary>
    /// 功率谱算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public async Task<PowerSpectrumResponse> PowerSpectrumAsync(float[] accData, float sampleRate)
    {
        var request = new PowerSpectrumRequest
        {
            AccData = {accData},
            SampleRate = sampleRate
        };
        
        return await _client.PowerSpectrumAlgAsync(request);
    }
}